'mvd (MakeVirtualDirectory) VDIRNAME LOCALPATH, ISAPP

Dim vdir, path, isApp
Const IIS_ROOT = "IIS://localhost/W3SVC/1/Root"

Sub Main()
    GetParams
    WScript.Echo "Creating VDIR: " & vdir & " at " & path & " isApp " & isApp
    CreateVDir vdir, path, isApp
    WScript.Echo "VDIR: " & vdir & " Created Successfully"
End Sub

Sub GetParams()
    If Wscript.Arguments.Count > 2 Then
        vdir = Wscript.Arguments(0)
        path = GetFullPath(Wscript.Arguments(1))   
        isApp = CBool(WScript.Arguments(2))     
    Else
        WScript.Echo "Badusage: " & vbNewLine &  "mvd VDIR PATH ISAPP"
        WSCript.Quit    
    End If    
End Sub

Function GetFullPath(path)
    Dim fso 
    Set fso = WScript.CreateObject( "Scripting.FileSystemObject" )
	GetFullPath = fso.GetFolder( path ).Path
End Function

Sub CreateVDir(vdir, path, createApp)
    Dim iis, v    
    Set iis = GetObject(IIS_ROOT)
    Set v = iis.Create("IISWebVirtualDir", vdir )        
    v.Path = path    
    
    if (createApp=True) Then    
        v.AccessScript  = True
	    v.AccessExecute = True
	    v.AppCreate True
	Else
	    v.AccessScript  = False
	    v.AccessExecute = False
	End If
	
    v.SetInfo 
    Set v = Nothing
    Set iis = Nothing          
End Sub



Call Main()

    